/**
 * 构造秒针
 */
function Second(color) {
  //如果color为真，那么color的值为color  否则值为red；
  //indefined为假
  this.fillColor = color || 'red';
  Control.call(this);
}
Second.prototype = Object.create(Control.prototype);
Second.prototype.constructor = Second;

//返回secondshow方法中需要的参数集合
Second.prototype.showPara = function () {
  var args = {};
  var time = new Date().getSeconds();
  args.duration = 60;
  args.delay = -(45 + time);
  args.zIndex = 10;
  return args;
};
Second.prototype.layoutPara = function () {
  var args = {};
  //指针圆周运动的半径
  args.r = Control.cRadius * 0.8;
  //指针转动时超出原点的长度
  args.offsetR = args.r * 0.15;
  args.height = args.r * 0.03;
  return args;
};
Second.prototype.show = function () {
  Control.prototype.show.call(this);
  var args = this.showPara();
  //延迟正值为等待n秒开始动画  为负值的时候跳过n秒进入动画
  this.ele.style.animationDelay = args.delay + 's';
  this.ele.style.animationName = 'rotate';
  this.ele.style.animationDuration = args.duration + 's';
  this.ele.style.animationTimingFunction = 'linear';
  this.ele.style.animationIterationCount = 'infinite';
  this.ele.style.backgroundColor = this.fillColor;
  this.ele.style.zIndex = args.zIndex;
};
Second.prototype.layout = function () {
  var args = this.layoutPara();
  this.ele.style.width = args.offsetR + args.r + 'px';
  this.ele.style.height = args.height + 'px';
  this.ele.style.borderRadius = (args.height * 2) / 4 + 'px';
  this.ele.style.left = Control.c_x - args.offsetR + 'px';
  this.ele.style.top = Control.c_y - parseInt(this.ele.style.height) / 2 + 'px';
  this.ele.style.transformOrigin = args.offsetR + 'px center';
};
